import request from '@/utils/request'
/*
  params 会自动进行url拼接，其它类似name、search这些则不会自动拼接
*/

// 用户增删改查
export function listPermission(params) {
  return request({
    url: '/permission/',
    method: 'get',
    params
  })
}

export function viewPermission(id) {
  return request({
    url: '/permission/' + id + '/',
    method: 'get'
  })
}

export function addPermission(data) {
  return request({
    url: '/permission/',
    method: 'post',
    data
  })
}

export function editPermission(id, data) {
  return request({
    url: '/permission/' + id + '/',
    method: 'put',
    data
  })
}

export function delPermission(id) {
  return request({
    url: '/permission/' + id,
    method: 'delete'
  })
}

// 菜单树
export function treePermission() {
  return request({
    url: '/tree/permissions/',
    method: 'get'
  })
}

// 检查权限名是否存在
export function checkPermissionName(params) {
  return request({
    url: '/check/permission/name/',
    method: 'get',
    params
  })
}

// 检查方法名是否存在
export function checkPermissionMethod(params) {
  return request({
    url: '/check/permission/method/',
    method: 'get',
    params
  })
}

// 检查父级菜单是否等于权限名
export function checkPermissionPid(params) {
  return request({
    url: '/check/permission/pid/',
    method: 'get',
    params
  })
}
